#pragma once
#include "log.hpp"
#include <vector>
#include <bitset>
#include <memory>
#include <unordered_map>
#include <string.h>

class my_file
{
private:
    std::string _master;
    std::string _name;
    std::string _addr;
    std::string _message;
    size_t _size;
    bool _run;
    bool _read;
    bool _write; // bitset可以改良

public:
    my_file(std::string mater, std::string name, std::string addr) : _master(mater), _name(name), _addr(addr)
    {
        _size = 0;
        _run = 1;
        _read = 1;
        _write = 1;
    }

    void set_read(bool read)
    {
        _read = read;
    }

    void set_write(bool write)
    {
        _write = write;
    }

    void set_run(bool run)
    {
        _run = run;
    }
    bool ret_read()
    {
        return _read;
    }

    bool ret_write()
    {
        return _write;
    }

    bool ret_run()
    {
        return _run;
    }

    std::string get_message()
    {
        return _message;
    }

    std::string master()
    {
        return _master;
    }
    void set_file_no()
    {
        _run = 0;
        _write = 0;
        _read = 0;
    }
    void set_message(const std::string &str)
    {
        _message = str;
        _size = str.size();
    }

    std::string print()
    {
        std::string ret = _name + " ";
        if (_read)
            ret = ret + "r";
        else
            ret = ret + "-";

        if (_write)
            ret = ret + "w";
        else
            ret = ret + "-";

        if (_run)
            ret = ret + "x";
        else
            ret = ret + "-";
        ret += " ";
        ret += _master;
        ret += " ";
        ret += std::to_string(_size);
        ret += " ";
        ret += _addr;
        return ret;
    }
};